import React, { useMemo } from 'react';

const App = (props: any) => {

  const { value, _dataIndex, columns } = props;

  const columnsOptions = useMemo(() => columns?.filter((item: any) => item.dataIndex === _dataIndex), [_dataIndex, columns])

  const realValue = useMemo(() => {
    const lng = window.localStorage.i18nextLng;
    let statusTransfer = {};

    try {
      statusTransfer = JSON.parse(columnsOptions[0]?.[lng === 'en' ? 'statusTransferEn' : 'statusTransfer'] || '{}'); 
    } catch (error) {}

    if (Object.keys(statusTransfer).length) {
      return statusTransfer[value] || value
    }else {
      if(value === true) return window.$app.t('true');
      if(value === false) return window.$app.t('false');
    }
    return value
  }, [columnsOptions, value])

  return <span>{realValue}</span>
};

export default App;
